package com.xp.tinyurl.admin.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xp.tinyurl.common.base.ResultVO;
import com.xp.tinyurl.common.base.ResultVOBuilder;
import com.xp.tinyurl.common.enums.BusinessLineEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 通用接口
 * @Author chengguo.pei
 * @Date 2021/9/26 15:54
 */
@Slf4j
@RequestMapping("/admin/common")
@RestController
public class CommonController {

    /**
     * 获取业务线
     * @return
     */
    @RequestMapping(value = "/getBusinessLine")
    public ResultVO getBusinessLine(){
        JSONArray jsonArray = new JSONArray();
        for(BusinessLineEnum bl : BusinessLineEnum.values()){
            JSONObject jsonObj = new JSONObject();
            jsonObj.put("code", bl.getCode());
            jsonObj.put("value", bl.getDesc());
            jsonArray.add(jsonObj);
        }
        return ResultVOBuilder.success(jsonArray);
    }


}
